<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://www.springside.org.cn/tags/shiro" %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<html>
<head>
	<title>首页管理</title>

	<!-- 使用bootbox的增强式alert/confirm/prompt -->	
	<script src="${ctx}/static/metronic/assets/plugins/bootbox/bootbox.min.js" type="text/javascript"></script>
			<link rel="stylesheet" type="text/css" href="${ctx}/static/metronic/assets/plugins/bootstrap-datepicker/css/datepicker.css"/>
	<script type="text/javascript" src="${ctx}/static/metronic/assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
	<script>
	jQuery(document).ready(function() {       
        if (jQuery().datepicker) {
        	var start ="";
        	 $('#search_beginTime').datepicker({
        		  format: 'yyyy-mm-dd',
        		        weekStart: 1,
        		        autoclose: true,
        		        todayBtn: 'linked',
        		        language: 'zh-CN'
        		 }).on('changeDate',function(ev){
        		  var startTime = ev.date.valueOf();
        		  start=startTime;
        		   });
        		 $('#search_endTime').datepicker({
        		  format: 'yyyy-mm-dd',
        		        weekStart: 1,
        		        autoclose: true,
        		        todayBtn: 'linked',
        		        language: 'zh-CN'
        		 }).on('changeDate',function(ev){
        		  var endTime = ev.date.valueOf();
        		  end = endTime;
        		  if(end<start){
        		   //alert("结束时间不能小于开始时间！");
        		   mes();
        		   $("#search_endTime").val("");
        		  }else{
        		   
        		  }
        		 });
        		 
    /*         $('.date-picker').datepicker({
            	format: "yyyy-mm-dd",
                rtl: App.isRTL(),
                autoclose: true
            }); */
            $('body').removeClass("modal-open"); // fix bug when inline picker is used in modal
        }
	});  
	
	
	
	</script>
	<script>
	//http://bootboxjs.com/
	function publish(id){
		bootbox.confirm("确实发布这条首页？", function(result) {
            if(result){
				location.href = "${ctx}/selfConstruction/publish/" + id;
            }
        }); 
	}
	function remove(id){
		bootbox.confirm("您确认要删除吗？", function(result) {
            if(result){
				location.href = "${ctx}/selfConstruction/delete/" + id;
            }
        }); 
	}
	function setMain(id){
		bootbox.confirm("确实设置这条记录为首页吗？", function(result) {
            if(result){
				location.href = "${ctx}/selfConstruction/setMain/" + id;
            }
        }); 
	}
	function mes(){
		bootbox.alert("结束时间不能小于开始时间！"); 
	}
	
	</script>
	
	<!-- select2组合框 -->
	<link rel="stylesheet" type="text/css" href="${ctx}/static/metronic/assets/plugins/select2/select2_metro.css"/>
	<script type="text/javascript" src="${ctx}/static/metronic/assets/plugins/select2/select2.min.js"></script>
	
</head>

<body>
<!-- BEGIN CONTENT -->
	<div class="page-content-wrapper">
		<div class="page-content">
			<!-- 提示信息 -->
			<c:if test="${not empty message}">
				<div id="message" class="alert alert-${not empty messageType ? messageType : 'success'}"><button data-dismiss="alert" class="close">×</button>${message}</div>
			</c:if>
			<div class="portlet-body">
			<form class="form-inline" action="#">
				发布日期：
				<div class="form-group">
					<label class="sr-only" for="search_beginTime">发布日期：</label>
					<input type="text" id="search_beginTime" name="search_beginTime" class="form-control date-picker" placeholder="" value="${param.search_beginTime}"/>
				</div>
				至
				<div class="form-group">
					<label class="sr-only" for="search_endTime">至</label>
					<input type="text" id="search_endTime" name="search_endTime" class="form-control date-picker" placeholder="" value="${param.search_endTime}"/>
				</div>
				
				所属栏目：
						<div class="form-group">
					<label class="sr-only" for="search_column">所属栏目</label>
					<select name="search_classify" id="search_classify" class="form-control input-small select2me" data-placeholder="按栏目查询">
						<option value="">全部</option>
						<c:forEach items="${types}" var="p">
								<option value="${p.key}" ${param.search_classify==p.key ? "selected=\"selected\"" : ""}>${p.value}</option>
							</c:forEach>
					</select>
				</div>
				文章标题：
				<div class="form-group">
					<label class="sr-only" for="search_title">文章标题：</label>
					<input type="text" id="search_title" name="search_title" class="form-control" placeholder="" value="${param.search_title}"/>
				</div>
				<button type="submit" class="btn btn-default">检索</button>
			</form>
				</div>
			<hr>
			
			<div class="row list-buttons">
				<div class="col-md-12">
					<a href="${ctx}/selfConstruction/create" class="btn green">添加</a>
				</div>
			</div>
			
			<!-- 数据表格 -->
			<!-- BEGIN PAGE HEADER-->
			<div class="row">
				<div class="col-md-12">
					<!-- BEGIN SAMPLE TABLE PORTLET-->
					<div class="portlet box green">
						<div class="portlet-title">
							<div class="caption">
								<i class="fa fa-cogs"></i>列表
							</div>
						</div>
						<div class="portlet-body">
							<div class="table-responsive">
								<table class="table table-hover">
								<thead>
								<tr>
									<th>序号</th>
									<th>信息状态</th>
									<th>文章标题</th>
									<th>发布时间</th>
									<th>发布人</th>
									<th>所属栏目</th>
									<th>操作</th>
								</tr>
								</thead>
								<tbody>
								<c:forEach items="${selfConstructions.content}" varStatus="i" var="selfConstruction">
								<tr>
									<td>${i.index+1 }</td>
									<td>${statuss[selfConstruction.status]}</td>
									<td>${selfConstruction.title}</td>
									<td><fmt:formatDate value="${selfConstruction.pubdate}" pattern="yyyy-MM-dd HH:mm"/></td>
									<td>${users[selfConstruction.user]}</td>
									<td>${types[selfConstruction.classify]}</td>
									
									<td>
										<a href="${ctx}/selfConstruction/update/${selfConstruction.id}" class="btn default btn-xs purple"><i class="fa fa-edit"> </i> 修改</a>
										<a href="javascript:remove(${selfConstruction.id})" class="btn default btn-xs black"><i class="fa fa-trash-o"> </i> 删除</a>
										
									</td>
								</tr>
								</c:forEach>
								</tbody>
								</table>
							</div>
						</div>
					</div>
					<!-- END SAMPLE TABLE PORTLET-->
				</div>
			</div>
			<%-- 		--%>	<tags:pagination page="${selfConstructions}" paginationSize="10"/> 
			</div>
			</div>
			

	
</body>
</html>
